checkout: Deal gracefully with bad input
authorMatthias Clasen <mclasen@redhat.com>
Sat, 5 May 2012 22:11:27 +0000 (18:11 -0400)
committerColin Walters <walters@verbum.org>
Sun, 6 May 2012 13:23:49 +0000 (09:23 -0400)
I had a /ostree/gnomeos-3.4-i686-devel directory, and this caused
ostree --repo=repo checkout gnomeos-3.5-i686-devel
to segfault.

src/ostree/ot-builtin-checkout.c

index 57b818c78bfa35ff126d19e4de462b1fa82187a7..4ac817acead98fca6d4d57e0d02a6cb1a08cf184 100644 (file)
@@ -97,6 +97,13 @@ parse_commit_from_symlink (GFile        *symlink,
     goto out;
 
   target = g_file_info_get_symlink_target (file_info);
+  if (target == NULL)
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "Not a symbolic link");
+      goto out;
+    }
+
   last_dash = strrchr (target, '-');
   if (last_dash == NULL)
     {